package utils

import base.DuoyuConfig
import java.io.File
import java.util.logging.FileHandler
import java.util.logging.Logger

object LogUtil{

    val DEBUG = DuoyuConfig.DEV_MODE

    private val logger: Logger by lazy {
        Logger.getGlobal()
    }

    fun s(tag: String, log: String){
        if (!DEBUG) return
        logger.severe("$tag -> $log")
    }

    fun w(tag: String, log: String){
        if (!DEBUG) return
        logger.warning("$tag -> $log")
    }

    fun i(tag: String, log: String){
        if (!DEBUG) return
        logger.info("$tag -> $log")
    }

    fun setLog2File(path: String){
        val fileHandler = FileHandler()
        logger.addHandler(fileHandler)
    }

}